<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>8.1.5 Data Binding 3.2.11</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="../css/main.css" type="text/css" media="screen, print" title="Style" charset="utf-8"/>
    <link rel="stylesheet" href="../css/pdf.css" type="text/css" media="print" title="PDF" charset="utf-8"/>
    <script type="text/javascript">
function addJsClass() {
    var classes = document.body.className.split(" ");
    classes.push("js");
    document.body.className = classes.join(" ");
}
    </script>
</head>

<body class="body" onload="addJsClass();">
<div id="navigation">
    <div class="navTitle">
        
        The Grails Framework
    </div>
    <div class="navLinks">
        <ul>
            <li>
                <div id="nav-summary" onmouseover="toggleNavSummary(false)" onmouseout="toggleNavSummary(true)">
                    <a href="../../guide/index.html" class="button">Table of contents</a>

                    <div id="nav-summary-childs" style="display:none;">
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/introduction.html"><strong>1</strong><span>Introduction</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/gettingStarted.html"><strong>2</strong><span>Getting Started</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/upgrading.html"><strong>3</strong><span>Upgrading</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/conf.html"><strong>4</strong><span>Configuration</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/commandLine.html"><strong>5</strong><span>The Command Line</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/profiles.html"><strong>6</strong><span>Application Profiles</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/GORM.html"><strong>7</strong><span>Object Relational Mapping (GORM)</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/theWebLayer.html"><strong>8</strong><span>The Web Layer</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/traits.html"><strong>9</strong><span>Traits</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/webServices.html"><strong>10</strong><span>Web Services</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/async.html"><strong>11</strong><span>Asynchronous Programming</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/validation.html"><strong>12</strong><span>Validation</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/services.html"><strong>13</strong><span>The Service Layer</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/staticTypeCheckingAndCompilation.html"><strong>14</strong><span>Static Type Checking And Compilation</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/testing.html"><strong>15</strong><span>Testing</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/i18n.html"><strong>16</strong><span>Internationalization</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/security.html"><strong>17</strong><span>Security</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/plugins.html"><strong>18</strong><span>Plugins</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/spring.html"><strong>19</strong><span>Grails and Spring</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/hibernate.html"><strong>20</strong><span>Grails and Hibernate</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/scaffolding.html"><strong>21</strong><span>Scaffolding</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/deployment.html"><strong>22</strong><span>Deployment</span></a>
                        </div>
                        
                        <div class="toc-item" style="margin-left:0"><a href="../../guide/contributing.html"><strong>23</strong><span>Contributing to Grails</span></a>
                        </div>
                        
                    </div>
                </div>
            </li>
            <li class="separator selected">
                <a id="ref-button" onclick="localToggle(); return false;" href="#">Quick Reference</a>
            </li>
        </ul>
    </div>


</div>

<table id="colset" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td id="col1">
            <div id="main" class="corner-all">

                
                    <div class="toc-item prev-left"><a href="../../guide/GORM.html">&lt;&lt; <strong>7</strong><span>Object Relational Mapping (GORM)</span></a></div>
                

                <span id='toggle-col1' class="toggle">(<a href="#" onclick="localToggle(); return false;">Quick Reference</a>)</span>

                
                    <div class="toc-item next-right"><a href="../../guide/traits.html"><strong>9</strong><span>Traits</span> >></a></div>
                


                <div class="project">
                    <h1>8.1.5 Data Binding</h1>

                    <p><strong>Version:</strong> 3.2.11</p>
                </div>

                

                
<a name="7.1.6 Data Binding"><!-- Legacy link --></a>
<h2 id="dataBinding">8.1.5 Data Binding</h2>

<div class='contribute-btn'>
    <button type='button' class='btn btn-default' onclick='window.location.href="https://github.com/grails/grails-doc/edit/3.2.x/src/en/guide/theWebLayer/controllers/dataBinding.adoc"'>
        <i class='fa fa-pencil-square-o'></i> Improve this doc
    </button>
</div>


<div class="paragraph">
<p>Data binding is the act of "binding" incoming request parameters onto the properties of an object or an entire graph of objects. Data binding should deal with all necessary type conversion since request parameters, which are typically delivered by a form submission, are always strings whilst the properties of a Groovy or Java object may well not be.</p>
</div>
<div class="sect3">
<h4 id="_map_based_binding">Map Based Binding</h4>
<div class="paragraph">
<p>The data binder is capable of converting and assigning values in a Map to properties of an object.  The binder will associate entries in the Map to properties of the object using the keys in the Map that have values which correspond to property names on the object.  The following code demonstrates the basics:</p>
</div>
<div class="listingblock">
<div class="title">grails-app/domain/Person.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">Person</span> {
    <span class="predefined-type">String</span> firstName
    <span class="predefined-type">String</span> lastName
    <span class="predefined-type">Integer</span> age
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> bindingMap = [<span class="key">firstName</span>: <span class="string"><span class="delimiter">'</span><span class="content">Peter</span><span class="delimiter">'</span></span>, <span class="key">lastName</span>: <span class="string"><span class="delimiter">'</span><span class="content">Gabriel</span><span class="delimiter">'</span></span>, <span class="key">age</span>: <span class="integer">63</span>]

<span class="keyword">def</span> person = <span class="keyword">new</span> Person(bindingMap)

<span class="keyword">assert</span> person.firstName == <span class="string"><span class="delimiter">'</span><span class="content">Peter</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.lastName == <span class="string"><span class="delimiter">'</span><span class="content">Gabriel</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.age == <span class="integer">63</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>To update properties of a domain object you may assign a Map to the <code>properties</code> property of the domain class:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> bindingMap = [<span class="key">firstName</span>: <span class="string"><span class="delimiter">'</span><span class="content">Peter</span><span class="delimiter">'</span></span>, <span class="key">lastName</span>: <span class="string"><span class="delimiter">'</span><span class="content">Gabriel</span><span class="delimiter">'</span></span>, <span class="key">age</span>: <span class="integer">63</span>]

<span class="keyword">def</span> person = Person.get(someId)
person.properties = bindingMap

<span class="keyword">assert</span> person.firstName == <span class="string"><span class="delimiter">'</span><span class="content">Peter</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.lastName == <span class="string"><span class="delimiter">'</span><span class="content">Gabriel</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.age == <span class="integer">63</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The binder can populate a full graph of objects using Maps of Maps.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">Person</span> {
    <span class="predefined-type">String</span> firstName
    <span class="predefined-type">String</span> lastName
    <span class="predefined-type">Integer</span> age
    Address homeAddress
}

<span class="type">class</span> <span class="class">Address</span> {
    <span class="predefined-type">String</span> county
    <span class="predefined-type">String</span> country
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> bindingMap = [<span class="key">firstName</span>: <span class="string"><span class="delimiter">'</span><span class="content">Peter</span><span class="delimiter">'</span></span>, <span class="key">lastName</span>: <span class="string"><span class="delimiter">'</span><span class="content">Gabriel</span><span class="delimiter">'</span></span>, <span class="key">age</span>: <span class="integer">63</span>, <span class="key">homeAddress</span>: [<span class="key">county</span>: <span class="string"><span class="delimiter">'</span><span class="content">Surrey</span><span class="delimiter">'</span></span>, <span class="key">country</span>: <span class="string"><span class="delimiter">'</span><span class="content">England</span><span class="delimiter">'</span></span>] ]

<span class="keyword">def</span> person = <span class="keyword">new</span> Person(bindingMap)

<span class="keyword">assert</span> person.firstName == <span class="string"><span class="delimiter">'</span><span class="content">Peter</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.lastName == <span class="string"><span class="delimiter">'</span><span class="content">Gabriel</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.age == <span class="integer">63</span>
<span class="keyword">assert</span> person.homeAddress.county == <span class="string"><span class="delimiter">'</span><span class="content">Surrey</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.homeAddress.country == <span class="string"><span class="delimiter">'</span><span class="content">England</span><span class="delimiter">'</span></span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_binding_to_collections_and_maps">Binding To Collections And Maps</h4>
<div class="paragraph">
<p>The data binder can populate and update Collections and Maps.  The following code shows a simple example of populating a <code>List</code> of objects in a domain class:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">Band</span> {
    <span class="predefined-type">String</span> name
    <span class="directive">static</span> hasMany = [<span class="key">albums</span>: Album]
    <span class="predefined-type">List</span> albums
}

<span class="type">class</span> <span class="class">Album</span> {
    <span class="predefined-type">String</span> title
    <span class="predefined-type">Integer</span> numberOfTracks
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> bindingMap = [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Genesis</span><span class="delimiter">'</span></span>,
                  <span class="string"><span class="delimiter">'</span><span class="content">albums[0]</span><span class="delimiter">'</span></span>: [<span class="key">title</span>: <span class="string"><span class="delimiter">'</span><span class="content">Foxtrot</span><span class="delimiter">'</span></span>, <span class="key">numberOfTracks</span>: <span class="integer">6</span>],
                  <span class="string"><span class="delimiter">'</span><span class="content">albums[1]</span><span class="delimiter">'</span></span>: [<span class="key">title</span>: <span class="string"><span class="delimiter">'</span><span class="content">Nursery Cryme</span><span class="delimiter">'</span></span>, <span class="key">numberOfTracks</span>: <span class="integer">7</span>]]

<span class="keyword">def</span> band = <span class="keyword">new</span> Band(bindingMap)

<span class="keyword">assert</span> band.name == <span class="string"><span class="delimiter">'</span><span class="content">Genesis</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> band.albums.size() == <span class="integer">2</span>
<span class="keyword">assert</span> band.albums[<span class="integer">0</span>].title == <span class="string"><span class="delimiter">'</span><span class="content">Foxtrot</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> band.albums[<span class="integer">0</span>].numberOfTracks == <span class="integer">6</span>
<span class="keyword">assert</span> band.albums[<span class="integer">1</span>].title == <span class="string"><span class="delimiter">'</span><span class="content">Nursery Cryme</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> band.albums[<span class="integer">1</span>].numberOfTracks == <span class="integer">7</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>That code would work in the same way if <code>albums</code> were an array instead of a <code>List</code>.</p>
</div>
<div class="paragraph">
<p>Note that when binding to a <code>Set</code> the structure of the <code>Map</code> being bound to the <code>Set</code> is the same as that of a <code>Map</code> being bound to a <code>List</code> but since a <code>Set</code> is unordered, the indexes don&#8217;t necessarily correspond to the order of elements in the <code>Set</code>.  In the code example above, if <code>albums</code> were a <code>Set</code> instead of a <code>List</code>, the <code>bindingMap</code> could look exactly the same but 'Foxtrot' might be the first album in the <code>Set</code> or it might be the second.  When updating existing elements in a <code>Set</code> the <code>Map</code> being assigned to the <code>Set</code> must have <code>id</code> elements in it which represent the element in the <code>Set</code> being updated, as in the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="comment">/*
 * The value of the indexes 0 and 1 in albums[0] and albums[1] are arbitrary
 * values that can be anything as long as they are unique within the Map.
 * They do not correspond to the order of elements in albums because albums
 * is a Set.
 */</span>
<span class="keyword">def</span> bindingMap = [<span class="string"><span class="delimiter">'</span><span class="content">albums[0]</span><span class="delimiter">'</span></span>: [<span class="key">id</span>: <span class="integer">9</span>, <span class="key">title</span>: <span class="string"><span class="delimiter">'</span><span class="content">The Lamb Lies Down On Broadway</span><span class="delimiter">'</span></span>]
                  <span class="string"><span class="delimiter">'</span><span class="content">albums[1]</span><span class="delimiter">'</span></span>: [<span class="key">id</span>: <span class="integer">4</span>, <span class="key">title</span>: <span class="string"><span class="delimiter">'</span><span class="content">Selling England By The Pound</span><span class="delimiter">'</span></span>]]

<span class="keyword">def</span> band = Band.get(someBandId)

<span class="comment">/*
 * This will find the Album in albums that has an id of 9 and will set its title
 * to 'The Lamb Lies Down On Broadway' and will find the Album in albums that has
 * an id of 4 and set its title to 'Selling England By The Pound'.  In both
 * cases if the Album cannot be found in albums then the album will be retrieved
 * from the database by id, the Album will be added to albums and will be updated
 * with the values described above.  If a Album with the specified id cannot be
 * found in the database, then a binding error will be created and associated
 * with the band object.  More on binding errors later.
 */</span>
band.properties = bindingMap</code></pre>
</div>
</div>
<div class="paragraph">
<p>When binding to a <code>Map</code> the structure of the binding <code>Map</code> is the same as the structure of a <code>Map</code> used for binding to a <code>List</code> or a <code>Set</code> and the index inside of square brackets corresponds to the key in the <code>Map</code> being bound to.  See the following code:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">Album</span> {
    <span class="predefined-type">String</span> title
    <span class="directive">static</span> hasMany = [<span class="key">players</span>: Player]
    <span class="predefined-type">Map</span> players
}

<span class="type">class</span> <span class="class">Player</span> {
    <span class="predefined-type">String</span> name
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> bindingMap = [<span class="key">title</span>: <span class="string"><span class="delimiter">'</span><span class="content">The Lamb Lies Down On Broadway</span><span class="delimiter">'</span></span>,
                  <span class="string"><span class="delimiter">'</span><span class="content">players[guitar]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Steve Hackett</span><span class="delimiter">'</span></span>],
                  <span class="string"><span class="delimiter">'</span><span class="content">players[vocals]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Peter Gabriel</span><span class="delimiter">'</span></span>],
                  <span class="string"><span class="delimiter">'</span><span class="content">players[keyboards]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Tony Banks</span><span class="delimiter">'</span></span>]]

<span class="keyword">def</span> album = <span class="keyword">new</span> Album(bindingMap)

<span class="keyword">assert</span> album.title == <span class="string"><span class="delimiter">'</span><span class="content">The Lamb Lies Down On Broadway</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.size() == <span class="integer">3</span>
<span class="keyword">assert</span> album.players.guitar.name == <span class="string"><span class="delimiter">'</span><span class="content">Steve Hackett</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.vocals.name == <span class="string"><span class="delimiter">'</span><span class="content">Peter Gabriel</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.keyboards.name == <span class="string"><span class="delimiter">'</span><span class="content">Tony Banks</span><span class="delimiter">'</span></span></code></pre>
</div>
</div>
<div class="paragraph">
<p>When updating an existing <code>Map</code>, if the key specified in the binding <code>Map</code> does not exist in the <code>Map</code> being bound to then a new value will be created and added to the <code>Map</code> with the specified key as in the following example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> bindingMap = [<span class="key">title</span>: <span class="string"><span class="delimiter">'</span><span class="content">The Lamb Lies Down On Broadway</span><span class="delimiter">'</span></span>,
                  <span class="string"><span class="delimiter">'</span><span class="content">players[guitar]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Steve Hackett</span><span class="delimiter">'</span></span>],
                  <span class="string"><span class="delimiter">'</span><span class="content">players[vocals]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Peter Gabriel</span><span class="delimiter">'</span></span>],
                  <span class="string"><span class="delimiter">'</span><span class="content">players[keyboards]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Tony Banks</span><span class="delimiter">'</span></span>]]

<span class="keyword">def</span> album = <span class="keyword">new</span> Album(bindingMap)

<span class="keyword">assert</span> album.title == <span class="string"><span class="delimiter">'</span><span class="content">The Lamb Lies Down On Broadway</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.size() == <span class="integer">3</span>
<span class="keyword">assert</span> album.players.guitar.name == <span class="string"><span class="delimiter">'</span><span class="content">Steve Hackett</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.vocals.name  == <span class="string"><span class="delimiter">'</span><span class="content">Peter Gabriel</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.keyboards.name  == <span class="string"><span class="delimiter">'</span><span class="content">Tony Banks</span><span class="delimiter">'</span></span>

<span class="keyword">def</span> updatedBindingMap = [<span class="string"><span class="delimiter">'</span><span class="content">players[drums]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Phil Collins</span><span class="delimiter">'</span></span>],
                         <span class="string"><span class="delimiter">'</span><span class="content">players[keyboards]</span><span class="delimiter">'</span></span>: [<span class="key">name</span>: <span class="string"><span class="delimiter">'</span><span class="content">Anthony George Banks</span><span class="delimiter">'</span></span>]]

album.properties = updatedBindingMap

<span class="keyword">assert</span> album.title == <span class="string"><span class="delimiter">'</span><span class="content">The Lamb Lies Down On Broadway</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.size() == <span class="integer">4</span>
<span class="keyword">assert</span> album.players.guitar.name == <span class="string"><span class="delimiter">'</span><span class="content">Steve Hackett</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.vocals.name == <span class="string"><span class="delimiter">'</span><span class="content">Peter Gabriel</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.keyboards.name == <span class="string"><span class="delimiter">'</span><span class="content">Anthony George Banks</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> album.players.drums.name == <span class="string"><span class="delimiter">'</span><span class="content">Phil Collins</span><span class="delimiter">'</span></span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_binding_request_data_to_the_model">Binding Request Data to the Model</h4>
<div class="paragraph">
<p>The <a href="../ref/Controllers/params.html">params</a> object that is available in a controller has special behavior that helps convert dotted request parameter names into nested Maps that the data binder can work with.  For example, if a request includes request parameters named <code>person.homeAddress.country</code> and <code>person.homeAddress.city</code> with values 'USA' and 'St. Louis' respectively, <code>params</code> would include entries like these:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">[<span class="key">person</span>: [<span class="key">homeAddress</span>: [<span class="key">country</span>: <span class="string"><span class="delimiter">'</span><span class="content">USA</span><span class="delimiter">'</span></span>, <span class="key">city</span>: <span class="string"><span class="delimiter">'</span><span class="content">St. Louis</span><span class="delimiter">'</span></span>]]]</code></pre>
</div>
</div>
<div class="paragraph">
<p>There are two ways to bind request parameters onto the properties of a domain class. The first involves using a domain classes' Map constructor:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> <span class="function">save</span>() {
    <span class="keyword">def</span> b = <span class="keyword">new</span> <span class="predefined-type">Book</span>(params)
    b.save()
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The data binding happens within the code <code>new Book(params)</code>. By passing the <a href="../ref/Controllers/params.html">params</a> object to the domain class constructor Grails automatically recognizes that you are trying to bind from request parameters. So if we had an incoming request like:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code>/book/save?title=The%20Stand&amp;author=Stephen%20King</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then the <code>title</code> and <code>author</code> request parameters would automatically be set on the domain class. You can use the <a href="../ref/Domain%20Classes/properties.html">properties</a> property to perform data binding onto an existing instance:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> <span class="function">save</span>() {
    <span class="keyword">def</span> b = <span class="predefined-type">Book</span>.get(params.id)
    b.properties = params
    b.save()
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>This has the same effect as using the implicit constructor.</p>
</div>
<div class="paragraph">
<p>When binding an empty String (a String with no characters in it, not even spaces), the data binder will convert the empty String to null.  This simplifies the most common case where the intent is to treat an empty form field as having the value null since there isn&#8217;t a way to actually submit a null as a request parameter.  When this behavior is not desirable the application may assign the value directly.</p>
</div>
<div class="paragraph">
<p>The mass property binding mechanism will by default automatically trim all Strings at binding time.  To disable this behavior set the <code>grails.databinding.trimStrings</code> property to false in <code>grails-app/conf/application.groovy</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="comment">// the default value is true</span>
grails.databinding.trimStrings = <span class="predefined-constant">false</span>

<span class="comment">// ...</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The mass property binding mechanism will by default automatically convert all empty Strings to null at binding time.  To disable this behavior set the <code>grails.databinding.convertEmptyStringsToNull</code> property to false in <code>grails-app/conf/application.groovy</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="comment">// the default value is true</span>
grails.databinding.convertEmptyStringsToNull = <span class="predefined-constant">false</span>

<span class="comment">// ...</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>The order of events is that the String trimming happens and then null conversion happens so if <code>trimStrings</code> is <code>true</code> and <code>convertEmptyStringsToNull</code> is <code>true</code>, not only will empty Strings be converted to null but also blank Strings.  A blank String is any String such that the <code>trim()</code> method returns an empty String.</p>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
These forms of data binding in Grails are very convenient, but also indiscriminate. In other words, they will bind <em>all</em> non-transient, typed instance properties of the target object, including ones that you may not want bound. Just because the form in your UI doesn&#8217;t submit all the properties, an attacker can still send malign data via a raw HTTP request. Fortunately, Grails also makes it easy to protect against such attacks - see the section titled "Data Binding and Security concerns" for more information.
</td>
</tr>
</table>
</div>
</div>
<div class="sect3">
<h4 id="_data_binding_and_single_ended_associations">Data binding and Single-ended Associations</h4>
<div class="paragraph">
<p>If you have a <code>one-to-one</code> or <code>many-to-one</code> association you can use Grails' data binding capability to update these relationships too. For example if you have an incoming request such as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code>/book/save?author.id=20</code></pre>
</div>
</div>
<div class="paragraph">
<p>Grails will automatically detect the <code>.id</code> suffix on the request parameter and look up the <code>Author</code> instance for the given id when doing data binding such as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> b = <span class="keyword">new</span> <span class="predefined-type">Book</span>(params)</code></pre>
</div>
</div>
<div class="paragraph">
<p>An association property can be set to <code>null</code> by passing the literal <code>String</code> "null". For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code>/book/save?author.id=null</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_data_binding_and_many_ended_associations">Data Binding and Many-ended Associations</h4>
<div class="paragraph">
<p>If you have a one-to-many or many-to-many association there are different techniques for data binding depending of the association type.</p>
</div>
<div class="paragraph">
<p>If you have a <code>Set</code> based association (the default for a <code>hasMany</code>) then the simplest way to populate an association is to send a list of identifiers. For example consider the usage of <code>&lt;g:select&gt;</code> below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;g:select</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">from</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${Book.list()}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">size</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">5</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">multiple</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">yes</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">optionKey</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">id</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${author?.books}</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>This produces a select box that lets you select multiple values. In this case if you submit the form Grails will automatically use the identifiers from the select box to populate the <code>books</code> association.</p>
</div>
<div class="paragraph">
<p>However, if you have a scenario where you want to update the properties of the associated objects the this technique won&#8217;t work. Instead you use the subscript operator:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;g:textField</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[0].title</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">the Stand</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span>
<span class="tag">&lt;g:textField</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[1].title</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">the Shining</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>However, with <code>Set</code> based association it is critical that you render the mark-up in the same order that you plan to do the update in. This is because a <code>Set</code> has no concept of order, so although we&#8217;re referring to <code>books[0]</code> and <code>books[1]</code> it is not guaranteed that the order of the association will be correct on the server side unless you apply some explicit sorting yourself.</p>
</div>
<div class="paragraph">
<p>This is not a problem if you use <code>List</code> based associations, since a <code>List</code> has a defined order and an index you can refer to. This is also true of <code>Map</code> based associations.</p>
</div>
<div class="paragraph">
<p>Note also that if the association you are binding to has a size of two and you refer to an element that is outside the size of association:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;g:textField</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[0].title</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">the Stand</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span>
<span class="tag">&lt;g:textField</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[1].title</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">the Shining</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span>
<span class="tag">&lt;g:textField</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[2].title</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">Red Madder</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Then Grails will automatically create a new instance for you at the defined position.</p>
</div>
<div class="paragraph">
<p>You can bind existing instances of the associated type to a <code>List</code> using the same <code>.id</code> syntax as you would use with a single-ended association. For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;g:select</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[0].id</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">from</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${bookList}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${author?.books[0]?.id}</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span>

<span class="tag">&lt;g:select</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[1].id</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">from</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${bookList}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${author?.books[1]?.id}</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span>

<span class="tag">&lt;g:select</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[2].id</span><span class="delimiter">&quot;</span></span> <span class="attribute-name">from</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${bookList}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${author?.books[2]?.id}</span><span class="delimiter">&quot;</span></span> <span class="tag">/&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Would allow individual entries in the <code>books List</code> to be selected separately.</p>
</div>
<div class="paragraph">
<p>Entries at particular indexes can be removed in the same way too. For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;g:select</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">books[0].id</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">from</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${Book.list()}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${author?.books[0]?.id}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">noSelection</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">['null': '']</span><span class="delimiter">&quot;</span></span><span class="tag">/&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Will render a select box that will remove the association at <code>books[0]</code> if the empty option is chosen.</p>
</div>
<div class="paragraph">
<p>Binding to a <code>Map</code> property works the same way except that the list index in the parameter name is replaced by the map key:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="xml"><span class="tag">&lt;g:select</span> <span class="attribute-name">name</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">images[cover].id</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">from</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${Image.list()}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">value</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">${book?.images[cover]?.id}</span><span class="delimiter">&quot;</span></span>
          <span class="attribute-name">noSelection</span>=<span class="string"><span class="delimiter">&quot;</span><span class="content">['null': '']</span><span class="delimiter">&quot;</span></span><span class="tag">/&gt;</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>This would bind the selected image into the <code>Map</code> property <code>images</code> under a key of <code>"cover"</code>.</p>
</div>
<div class="paragraph">
<p>When binding to Maps, Arrays and Collections the data binder will automatically grow the size of the collections as necessary.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The default limit to how large the binder will grow a collection is 256. If the data binder encounters an entry that requires the collection be grown beyond that limit, the entry is ignored.  The limit may be configured by assigning a value to the <code>grails.databinding.autoGrowCollectionLimit</code> property in <code>application.groovy</code>.
</td>
</tr>
</table>
</div>
<div class="listingblock">
<div class="title">grails-app/conf/application.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="comment">// the default value is 256</span>
grails.databinding.autoGrowCollectionLimit = <span class="integer">128</span>

<span class="comment">// ...</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_data_binding_with_multiple_domain_classes">Data binding with Multiple domain classes</h4>
<div class="paragraph">
<p>It is possible to bind data to multiple domain objects from the <a href="../ref/Controllers/params.html">params</a> object.</p>
</div>
<div class="paragraph">
<p>For example so you have an incoming request to:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">/book/save?book.title=The%20Stand&amp;author.name=Stephen%20King</code></pre>
</div>
</div>
<div class="paragraph">
<p>You&#8217;ll notice the difference with the above request is that each parameter has a prefix such as <code>author.</code> or <code>book.</code> which is used to isolate which parameters belong to which type. Grails' <code>params</code> object is like a multi-dimensional hash and you can index into it to isolate only a subset of the parameters to bind.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> b = <span class="keyword">new</span> <span class="predefined-type">Book</span>(params.book)</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice how we use the prefix before the first dot of the <code>book.title</code> parameter to isolate only parameters below this level to bind. We could do the same with an <code>Author</code> domain class:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> a = <span class="keyword">new</span> Author(params.author)</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_data_binding_and_action_arguments">Data Binding and Action Arguments</h4>
<div class="paragraph">
<p>Controller action arguments are subject to request parameter data binding.  There are 2 categories of controller action arguments.  The first category is command objects.  Complex types are treated as command objects.  See the <a href="theWebLayer.html#commandObjects">Command Objects</a> section of the user guide for details.  The other category is basic object types.  Supported types are the 8 primitives, their corresponding type wrappers and <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html">java.lang.String</a>.  The default behavior is to map request parameters to action arguments by name:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">AccountingController</span> {

   <span class="comment">// accountNumber will be initialized with the value of params.accountNumber</span>
   <span class="comment">// accountType will be initialized with params.accountType</span>
   <span class="keyword">def</span> <span class="function">displayInvoice</span>(<span class="predefined-type">String</span> accountNumber, <span class="type">int</span> accountType) {
       <span class="comment">// ...</span>
   }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>For primitive arguments and arguments which are instances of any of the primitive type wrapper classes a type conversion has to be carried out before the request parameter value can be bound to the action argument.  The type conversion happens automatically.  In a case like the example shown above, the <code>params.accountType</code> request parameter has to be converted to an <code>int</code>.  If type conversion fails for any reason, the argument will have its default value per normal Java behavior (null for type wrapper references, false for booleans and zero for numbers) and a corresponding error will be added to the <code>errors</code> property of the defining controller.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">/accounting/displayInvoice?accountNumber=B59786&amp;accountType=bogusValue</code></pre>
</div>
</div>
<div class="paragraph">
<p>Since "bogusValue" cannot be converted to type int, the value of accountType will be zero, the controller&#8217;s <code>errors.hasErrors()</code> will be true, the controller&#8217;s <code>errors.errorCount</code> will be equal to 1 and the controller&#8217;s <code>errors.getFieldError('accountType')</code> will contain the corresponding error.</p>
</div>
<div class="paragraph">
<p>If the argument name does not match the name of the request parameter then the <code>@grails.web.RequestParameter</code> annotation may be applied to an argument to express the name of the request parameter which should be bound to that argument:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">import</span> <span class="include">grails.web.RequestParameter</span>

<span class="type">class</span> <span class="class">AccountingController</span> {

   <span class="comment">// mainAccountNumber will be initialized with the value of params.accountNumber</span>
   <span class="comment">// accountType will be initialized with params.accountType</span>
   <span class="keyword">def</span> <span class="function">displayInvoice</span>(<span class="annotation">@RequestParameter</span>(<span class="string"><span class="delimiter">'</span><span class="content">accountNumber</span><span class="delimiter">'</span></span>) <span class="predefined-type">String</span> mainAccountNumber, <span class="type">int</span> accountType) {
       <span class="comment">// ...</span>
   }
}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_data_binding_and_type_conversion_errors">Data binding and type conversion errors</h4>
<div class="paragraph">
<p>Sometimes when performing data binding it is not possible to convert a particular String into a particular target type. This results in a type conversion error. Grails will retain type conversion errors inside the <a href="../ref/Domain%20Classes/errors.html">errors</a> property of a Grails domain class. For example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">Book</span> {
    ...
    URL publisherURL
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Here we have a domain class <code>Book</code> that uses the <code>java.net.URL</code> class to represent URLs. Given an incoming request such as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="bash">/book/save?publisherURL=a-bad-url</code></pre>
</div>
</div>
<div class="paragraph">
<p>it is not possible to bind the string <code>a-bad-url</code> to the <code>publisherURL</code> property as a type mismatch error occurs. You can check for these like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> b = <span class="keyword">new</span> <span class="predefined-type">Book</span>(params)

<span class="keyword">if</span> (b.hasErrors()) {
    println <span class="string"><span class="delimiter">&quot;</span><span class="content">The value </span><span class="inline"><span class="inline-delimiter">${</span>b.errors.getFieldError(<span class="string"><span class="delimiter">'</span><span class="content">publisherURL</span><span class="delimiter">'</span></span>).rejectedValue<span class="inline-delimiter">}</span></span><span class="delimiter">&quot;</span></span> +
            <span class="string"><span class="delimiter">&quot;</span><span class="content"> is not a valid URL!</span><span class="delimiter">&quot;</span></span>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Although we have not yet covered error codes (for more information see the section on <a href="validation.html">validation</a>), for type conversion errors you would want a message from the <code>grails-app/i18n/messages.properties</code> file to use for the error. You can use a generic error message handler such as:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">typeMismatch.java.net.URL=The field {<span class="integer">0</span>} is not a valid <span class="predefined-type">URL</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Or a more specific one:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">typeMismatch.Book.publisherURL=The publisher <span class="predefined-type">URL</span> you specified is not a valid <span class="predefined-type">URL</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_the_bindusing_annotation">The BindUsing Annotation</h4>
<div class="paragraph">
<p>The <a href="http://docs.grails.org/3.2.11/api/grails/databinding/BindUsing.html">BindUsing</a> annotation may be used to define a custom binding mechanism for a particular field in a class.  Any time data binding is being applied to the field the closure value of the annotation will be invoked with 2 arguments.  The first argument is the object that data binding is being applied to and the second argument is <a href="http://docs.grails.org/3.2.11/api/grails/databinding/DataBindingSource.html">DataBindingSource</a> which is the data source for the data binding.  The value returned from the closure will be bound to the property.  The following example would result in the upper case version of the <code>name</code> value in the source being applied to the <code>name</code> field during data binding.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">import</span> <span class="include">grails.databinding.BindUsing</span>

<span class="type">class</span> <span class="class">SomeClass</span> {
    <span class="annotation">@BindUsing</span>({obj, source -&gt;

        <span class="comment">//source is DataSourceBinding which is similar to a Map</span>
        <span class="comment">//and defines getAt operation but source.name cannot be used here.</span>
        <span class="comment">//In order to get name from source use getAt instead as shown below.</span>

        source[<span class="string"><span class="delimiter">'</span><span class="content">name</span><span class="delimiter">'</span></span>]?.toUpperCase()
    })
    <span class="predefined-type">String</span> name
}</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Note that data binding is only possible when the name of the request parameter matches with the field name in the class.
Here, <code>name</code> from request parameters matches with <code>name</code> from <code>SomeClass</code>.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="http://docs.grails.org/3.2.11/api/grails/databinding/BindUsing.html">BindUsing</a> annotation may be used to define a custom binding mechanism for all of the fields on a particular class. When the annotation is applied to a class, the value assigned to the annotation should be a class which implements the <a href="http://docs.grails.org/3.2.11/api/grails/databinding/BindingHelper.html">BindingHelper</a> interface.  An instance of that class will be used any time a value is bound to a property in the class that this annotation has been applied to.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="annotation">@BindUsing</span>(SomeClassWhichImplementsBindingHelper)
<span class="type">class</span> <span class="class">SomeClass</span> {
    <span class="predefined-type">String</span> someProperty
    <span class="predefined-type">Integer</span> someOtherProperty
}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_custom_data_converters">Custom Data Converters</h4>
<div class="paragraph">
<p>The binder will do a lot of type conversion automatically.  Some applications may want to define their own mechanism for converting values and a simple way to do this is to write a class which implements <a href="http://docs.grails.org/3.2.11/api/grails/databinding/converters/ValueConverter.html">ValueConverter</a> and register an instance of that class as a bean in the Spring application context.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> com.myapp.converters

<span class="keyword">import</span> <span class="include">grails.databinding.converters.ValueConverter</span>

<span class="comment">/**
 * A custom converter which will convert String of the
 * form 'city:state' into an Address object.
 */</span>
<span class="type">class</span> <span class="class">AddressValueConverter</span> <span class="directive">implements</span> ValueConverter {

    <span class="type">boolean</span> canConvert(value) {
        value <span class="keyword">instanceof</span> <span class="predefined-type">String</span>
    }

    <span class="keyword">def</span> <span class="function">convert</span>(value) {
        <span class="keyword">def</span> pieces = value.split(<span class="string"><span class="delimiter">'</span><span class="content">:</span><span class="delimiter">'</span></span>)
        <span class="keyword">new</span> com.myapp.Address(<span class="key">city</span>: pieces[<span class="integer">0</span>], <span class="key">state</span>: pieces[<span class="integer">1</span>])
    }

    <span class="predefined-type">Class</span>&lt;?&gt; getTargetType() {
        com.myapp.Address
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>An instance of that class needs to be registered as a bean in the Spring application context.  The bean name is not important.  All beans that implemented ValueConverter will be automatically plugged in to the data binding process.</p>
</div>
<div class="listingblock">
<div class="title">grails-app/conf/spring/resources.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">beans = {
    addressConverter com.myapp.converters.AddressValueConverter
    <span class="comment">// ...</span>
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">Person</span> {
    <span class="predefined-type">String</span> firstName
    Address homeAddress
}

<span class="type">class</span> <span class="class">Address</span> {
    <span class="predefined-type">String</span> city
    <span class="predefined-type">String</span> state
}

<span class="keyword">def</span> person = <span class="keyword">new</span> Person()
person.properties = [<span class="key">firstName</span>: <span class="string"><span class="delimiter">'</span><span class="content">Jeff</span><span class="delimiter">'</span></span>, <span class="key">homeAddress</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">O'Fallon:Missouri</span><span class="delimiter">&quot;</span></span>]
<span class="keyword">assert</span> person.firstName == <span class="string"><span class="delimiter">'</span><span class="content">Jeff</span><span class="delimiter">'</span></span>
<span class="keyword">assert</span> person.homeAddress.city = <span class="string"><span class="delimiter">&quot;</span><span class="content">O'Fallon</span><span class="delimiter">&quot;</span></span>
<span class="keyword">assert</span> person.homeAddress.state = <span class="string"><span class="delimiter">'</span><span class="content">Missouri</span><span class="delimiter">'</span></span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_date_formats_for_data_binding">Date Formats For Data Binding</h4>
<div class="paragraph">
<p>A custom date format may be specified to be used when binding a String to a Date value by applying the <a href="http://docs.grails.org/3.2.11/api/grails/databinding/BindingFormat.html">BindingFormat</a> annotation to a Date field.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">import</span> <span class="include">grails.databinding.BindingFormat</span>

<span class="type">class</span> <span class="class">Person</span> {
    <span class="annotation">@BindingFormat</span>(<span class="string"><span class="delimiter">'</span><span class="content">MMddyyyy</span><span class="delimiter">'</span></span>)
    <span class="predefined-type">Date</span> birthDate
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>A global setting may be configured in <code>application.groovy</code> to define date formats which will be used application wide when binding to Date.</p>
</div>
<div class="listingblock">
<div class="title">grails-app/conf/application.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">grails.databinding.dateFormats = [<span class="string"><span class="delimiter">'</span><span class="content">MMddyyyy</span><span class="delimiter">'</span></span>, <span class="string"><span class="delimiter">'</span><span class="content">yyyy-MM-dd HH:mm:ss.S</span><span class="delimiter">'</span></span>, <span class="string"><span class="delimiter">&quot;</span><span class="content">yyyy-MM-dd'T'hh:mm:ss'Z'</span><span class="delimiter">&quot;</span></span>]</code></pre>
</div>
</div>
<div class="paragraph">
<p>The formats specified in <code>grails.databinding.dateFormats</code> will be attempted in the order in which they are included in the List.  If a property is marked with <code>@BindingFormat</code>, the <code>@BindingFormat</code> will take precedence over the values specified in <code>grails.databinding.dateFormats</code>.</p>
</div>
<div class="paragraph">
<p>The formats configured by default are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>yyyy-MM-dd HH:mm:ss.S</code></p>
</li>
<li>
<p><code>yyyy-MM-dd&#8217;T&#8217;hh:mm:ss&#8217;Z'</code></p>
</li>
<li>
<p><code>yyyy-MM-dd HH:mm:ss.S z</code></p>
</li>
<li>
<p><code>yyyy-MM-dd&#8217;T&#8217;HH:mm:ss.SSSX</code></p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_custom_formatted_converters">Custom Formatted Converters</h4>
<div class="paragraph">
<p>You may supply your own handler for the <a href="http://docs.grails.org/3.2.11/api/grails/databinding/BindingFormat.html">BindingFormat</a> annotation by writing a class which implements the <a href="http://docs.grails.org/3.2.11/api/grails/databinding/converters/FormattedValueConverter.html">FormattedValueConverter</a> interface and registering an instance of that class as a bean in the Spring application context.  Below is an example of a trivial custom String formatter that might convert the case of a String based on the value assigned to the BindingFormat annotation.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> com.myapp.converters

<span class="keyword">import</span> <span class="include">grails.databinding.converters.FormattedValueConverter</span>

<span class="type">class</span> <span class="class">FormattedStringValueConverter</span> <span class="directive">implements</span> FormattedValueConverter {
    <span class="keyword">def</span> <span class="function">convert</span>(value, <span class="predefined-type">String</span> format) {
        <span class="keyword">if</span>(<span class="string"><span class="delimiter">'</span><span class="content">UPPERCASE</span><span class="delimiter">'</span></span> == format) {
            value = value.toUpperCase()
        } <span class="keyword">else</span> <span class="keyword">if</span>(<span class="string"><span class="delimiter">'</span><span class="content">LOWERCASE</span><span class="delimiter">'</span></span> == format) {
            value = value.toLowerCase()
        }
        value
    }

    <span class="predefined-type">Class</span> getTargetType() {
        <span class="comment">// specifies the type to which this converter may be applied</span>
        <span class="predefined-type">String</span>
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>An instance of that class needs to be registered as a bean in the Spring application context.  The bean name is not important.  All beans that implemented FormattedValueConverter will be automatically plugged in to the data binding process.</p>
</div>
<div class="listingblock">
<div class="title">grails-app/conf/spring/resources.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">beans = {
    formattedStringConverter com.myapp.converters.FormattedStringValueConverter
    <span class="comment">// ...</span>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>With that in place the <code>BindingFormat</code> annotation may be applied to String fields to inform the data binder to take advantage of the custom converter.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">import</span> <span class="include">grails.databinding.BindingFormat</span>

<span class="type">class</span> <span class="class">Person</span> {
    <span class="annotation">@BindingFormat</span>(<span class="string"><span class="delimiter">'</span><span class="content">UPPERCASE</span><span class="delimiter">'</span></span>)
    <span class="predefined-type">String</span> someUpperCaseString

    <span class="annotation">@BindingFormat</span>(<span class="string"><span class="delimiter">'</span><span class="content">LOWERCASE</span><span class="delimiter">'</span></span>)
    <span class="predefined-type">String</span> someLowerCaseString

    <span class="predefined-type">String</span> someOtherString
}</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_localized_binding_formats">Localized Binding Formats</h4>
<div class="paragraph">
<p>The <code>BindingFormat</code> annotation supports localized format strings by using the optional <code>code</code> attribute.  If a value is assigned to the code attribute that value will be used as the message code to retrieve the binding format string from the <code>messageSource</code> bean in the Spring application context and that lookup will be localized.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">import</span> <span class="include">grails.databinding.BindingFormat</span>

<span class="type">class</span> <span class="class">Person</span> {
    <span class="annotation">@BindingFormat</span>(code=<span class="string"><span class="delimiter">'</span><span class="content">date.formats.birthdays</span><span class="delimiter">'</span></span>)
    <span class="predefined-type">Date</span> birthDate
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="error">#</span> grails-app/conf/i18n/messages.properties
date.formats.birthdays=MMddyyyy</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="error">#</span> grails-app/conf/i18n/messages_es.properties
date.formats.birthdays=ddMMyyyy</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_structured_data_binding_editors">Structured Data Binding Editors</h4>
<div class="paragraph">
<p>A structured data binding editor is a helper class which can bind structured request parameters to a property.  The common use case for structured binding is binding to a <code>Date</code> object which might be constructed from several smaller pieces of information contained in several request parameters with names like <code>birthday_month</code>, <code>birthday_date</code> and <code>birthday_year</code>.  The structured editor would retrieve all of those individual pieces of information and use them to construct a <code>Date</code>.</p>
</div>
<div class="paragraph">
<p>The framework provides a structured editor for binding to <code>Date</code> objects.  An application may register its own structured editors for whatever types are appropriate.  Consider the following classes:</p>
</div>
<div class="listingblock">
<div class="title">src/main/groovy/databinding/Gadget.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> databinding

<span class="type">class</span> <span class="class">Gadget</span> {
    <span class="predefined-type">Shape</span> expandedShape
    <span class="predefined-type">Shape</span> compressedShape
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="title">src/main/groovy/databinding/Shape.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> databinding

<span class="type">class</span> <span class="class">Shape</span> {
    <span class="type">int</span> area
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>A <code>Gadget</code> has 2 <code>Shape</code> fields.  A <code>Shape</code> has an <code>area</code> property.  It may be that the application wants to accept request parameters like <code>width</code> and <code>height</code> and use those to calculate the <code>area</code> of a <code>Shape</code> at binding time.  A structured binding editor is well suited for that.</p>
</div>
<div class="paragraph">
<p>The way to register a structured editor with the data binding process is to add an instance of the <a href="http://docs.grails.org/3.2.11/api/grails/databinding/TypedStructuredBindingEditor.html">grails.databinding.TypedStructuredBindingEditor</a> interface to the Spring application context.  The easiest way to implement the <code>TypedStructuredBindingEditor</code> interface is to extend the <a href="http://docs.grails.org/3.2.11/api/org/grails/databinding/converters/AbstractStructuredDateBindingEditor.html">org.grails.databinding.converters.AbstractStructuredBindingEditor</a> abstract class and override the <code>getPropertyValue</code> method as shown below:</p>
</div>
<div class="listingblock">
<div class="title">src/main/groovy/databinding/converters/StructuredShapeEditor.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> databinding.converters

<span class="keyword">import</span> <span class="include">databinding.Shape</span>

<span class="keyword">import</span> <span class="include">org.grails.databinding.converters.AbstractStructuredBindingEditor</span>

<span class="type">class</span> <span class="class">StructuredShapeEditor</span> <span class="directive">extends</span> AbstractStructuredBindingEditor&lt;<span class="predefined-type">Shape</span>&gt; {

    <span class="directive">public</span> <span class="predefined-type">Shape</span> getPropertyValue(<span class="predefined-type">Map</span> values) {
        <span class="comment">// retrieve the individual values from the Map</span>
        <span class="keyword">def</span> width = values.width <span class="keyword">as</span> <span class="type">int</span>
        <span class="keyword">def</span> height = values.height <span class="keyword">as</span> <span class="type">int</span>

        <span class="comment">// use the values to calculate the area of the Shape</span>
        <span class="keyword">def</span> area = width * height

        <span class="comment">// create and return a Shape with the appropriate area</span>
        <span class="keyword">new</span> <span class="predefined-type">Shape</span>(<span class="key">area</span>: area)
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>An instance of that class needs to be registered with the Spring application context:</p>
</div>
<div class="listingblock">
<div class="title">grails-app/conf/spring/resources.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy">beans = {
    shapeEditor databinding.converters.StructuredShapeEditor
    <span class="comment">// ...</span>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>When the data binder binds to an instance of the <code>Gadget</code> class it will check to see if there are request parameters with names <code>compressedShape</code> and <code>expandedShape</code> which have a value of "struct" and if they do exist, that will trigger the use of the <code>StructuredShapeEditor</code>.  The individual components of the structure need to have parameter names of the form propertyName_structuredElementName.  In the case of the <code>Gadget</code> class above that would mean that the <code>compressedShape</code> request parameter should have a value of "struct" and the <code>compressedShape_width</code> and <code>compressedShape_height</code> parameters should have values which represent the width and the height of the compressed <code>Shape</code>.  Similarly, the <code>expandedShape</code> request parameter should have a value of "struct" and the <code>expandedShape_width</code> and <code>expandedShape_height</code> parameters should have values which represent the width and the height of the expanded <code>Shape</code>.</p>
</div>
<div class="listingblock">
<div class="title">grails-app/controllers/demo/DemoController.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="type">class</span> <span class="class">DemoController</span> {

    <span class="keyword">def</span> <span class="function">createGadget</span>(Gadget gadget) {
        <span class="comment">/*
        /demo/createGadget?expandedShape=struct&amp;expandedShape_width=80&amp;expandedShape_height=30
                          &amp;compressedShape=struct&amp;compressedShape_width=10&amp;compressedShape_height=3

        */</span>

        <span class="comment">// with the request parameters shown above gadget.expandedShape.area would be 2400</span>
        <span class="comment">// and gadget.compressedShape.area would be 30</span>
        <span class="comment">// ...</span>
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Typically the request parameters with "struct" as their value would be represented by hidden form fields.</p>
</div>
</div>
<div class="sect3">
<h4 id="_data_binding_event_listeners">Data Binding Event Listeners</h4>
<div class="paragraph">
<p>The <a href="http://docs.grails.org/3.2.11/api/grails/databinding/events/DataBindingListener.html">DataBindingListener</a> interface provides a mechanism for listeners to be notified of data binding events.  The interface looks like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> grails.databinding.events;

<span class="keyword">import</span> <span class="include">grails.databinding.errors.BindingError</span>;

<span class="comment">/**
 * A listener which will be notified of events generated during data binding.
 *
 * @author Jeff Brown
 * @since 3.0
 * @see DataBindingListenerAdapter
 */</span>
<span class="directive">public</span> <span class="type">interface</span> DataBindingListener {

    <span class="comment">/**
     * @return true if the listener is interested in events for the specified type.
     */</span>
    <span class="type">boolean</span> supports(<span class="predefined-type">Class</span>&lt;?&gt; clazz);

    <span class="comment">/**
     * Called when data binding is about to start.
     *
     * @param target The object data binding is being imposed upon
     * @param errors the Spring Errors instance (a org.springframework.validation.BindingResult)
     * @return true if data binding should continue
     */</span>
    <span class="predefined-type">Boolean</span> beforeBinding(<span class="predefined-type">Object</span> target, <span class="predefined-type">Object</span> errors);

    <span class="comment">/**
     * Called when data binding is about to imposed on a property
     *
     * @param target The object data binding is being imposed upon
     * @param propertyName The name of the property being bound to
     * @param value The value of the property being bound
     * @param errors the Spring Errors instance (a org.springframework.validation.BindingResult)
     * @return true if data binding should continue, otherwise return false
     */</span>
    <span class="predefined-type">Boolean</span> beforeBinding(<span class="predefined-type">Object</span> target, <span class="predefined-type">String</span> propertyName, <span class="predefined-type">Object</span> value, <span class="predefined-type">Object</span> errors);

    <span class="comment">/**
     * Called after data binding has been imposed on a property
     *
     * @param target The object data binding is being imposed upon
     * @param propertyName The name of the property that was bound to
     * @param errors the Spring Errors instance (a org.springframework.validation.BindingResult)
     */</span>
    <span class="type">void</span> afterBinding(<span class="predefined-type">Object</span> target, <span class="predefined-type">String</span> propertyName, <span class="predefined-type">Object</span> errors);

    <span class="comment">/**
     * Called after data binding has finished.
     *
     * @param target The object data binding is being imposed upon
     * @param errors the Spring Errors instance (a org.springframework.validation.BindingResult)
     */</span>
    <span class="type">void</span> afterBinding(<span class="predefined-type">Object</span> target, <span class="predefined-type">Object</span> errors);

    <span class="comment">/**
     * Called when an error occurs binding to a property
     * @param error encapsulates information about the binding error
     * @param errors the Spring Errors instance (a org.springframework.validation.BindingResult)
     * @see BindingError
     */</span>
    <span class="type">void</span> bindingError(BindingError error, <span class="predefined-type">Object</span> errors);
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Any bean in the Spring application context which implements that interface will automatically be registered with the data binder.  The <a href="http://docs.grails.org/3.2.11/api/grails/databinding/events/DataBindingListenerAdapter.html">DataBindingListenerAdapter</a> class implements the <code>DataBindingListener</code> interface and provides default implementations for all of the methods in the interface so this class is well suited for subclassing so your listener class only needs to provide implementations for the methods your listener is interested in.</p>
</div>
</div>
<div class="sect3">
<h4 id="_using_the_data_binder_directly">Using The Data Binder Directly</h4>
<div class="paragraph">
<p>There are situations where an application may want to use the data binder directly.  For example, to do binding in a Service on some arbitrary object which is not a domain class.  The following will not work because the <code>properties</code> property is read only.</p>
</div>
<div class="listingblock">
<div class="title">src/main/groovy/bindingdemo/Widget.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> bindingdemo

<span class="type">class</span> <span class="class">Widget</span> {
    <span class="predefined-type">String</span> name
    <span class="predefined-type">Integer</span> size
}</code></pre>
</div>
</div>
<div class="listingblock">
<div class="title">grails-app/services/bindingdemo/WidgetService.groovy</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> bindingdemo

<span class="type">class</span> <span class="class">WidgetService</span> {

    <span class="keyword">def</span> <span class="function">updateWidget</span>(Widget widget, <span class="predefined-type">Map</span> data) {
        <span class="comment">// this will throw an exception because</span>
        <span class="comment">// properties is read-only</span>
        widget.properties = data
    }
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>An instance of the data binder is in the Spring application context with a bean name of <code>grailsWebDataBinder</code>.  That bean implements the <a href="http://docs.grails.org/3.2.11/api/grails/databinding/DataBinder.html">DataBinder</a> interface.  The following code demonstrates using the data binder directly.</p>
</div>
<div class="listingblock">
<div class="title">grails-app/services/bindingdmeo/WidgetService</div>
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">package</span> bindingdemo

<span class="keyword">import</span> <span class="include">grails.databinding.SimpleMapDataBindingSource</span>

<span class="type">class</span> <span class="class">WidgetService</span> {

    <span class="comment">// this bean will be autowired into the service</span>
    <span class="keyword">def</span> grailsWebDataBinder

    <span class="keyword">def</span> <span class="function">updateWidget</span>(Widget widget, <span class="predefined-type">Map</span> data) {
        grailsWebDataBinder.bind widget, data <span class="keyword">as</span> SimpleMapDataBindingSource
    }

}</code></pre>
</div>
</div>
<div class="paragraph">
<p>See the <a href="http://docs.grails.org/3.2.11/api/grails/databinding/DataBinder.html">DataBinder</a> documentation for more information about overloaded versions
of the <code>bind</code> method.</p>
</div>
</div>
<div class="sect3">
<h4 id="_data_binding_and_security_concerns">Data Binding and Security Concerns</h4>
<div class="paragraph">
<p>When batch updating properties from request parameters you need to be careful not to allow clients to bind malicious data to domain classes and be persisted in the database. You can limit what properties are bound to a given domain class using the subscript operator:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> p = Person.get(<span class="integer">1</span>)

p.properties[<span class="string"><span class="delimiter">'</span><span class="content">firstName</span><span class="delimiter">'</span></span>,<span class="string"><span class="delimiter">'</span><span class="content">lastName</span><span class="delimiter">'</span></span>] = params</code></pre>
</div>
</div>
<div class="paragraph">
<p>In this case only the <code>firstName</code> and <code>lastName</code> properties will be bound.</p>
</div>
<div class="paragraph">
<p>Another way to do this is is to use <a href="theWebLayer.html#commandObjects">Command Objects</a> as the target of data binding instead of domain classes. Alternatively there is also the flexible <a href="../ref/Controllers/bindData.html">bindData</a> method.</p>
</div>
<div class="paragraph">
<p>The <code>bindData</code> method allows the same data binding capability, but to arbitrary objects:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> p = <span class="keyword">new</span> Person()
bindData(p, params)</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>bindData</code> method also lets you exclude certain parameters that you don&#8217;t want updated:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> p = <span class="keyword">new</span> Person()
bindData(p, params, [<span class="key">exclude</span>: <span class="string"><span class="delimiter">'</span><span class="content">dateOfBirth</span><span class="delimiter">'</span></span>])</code></pre>
</div>
</div>
<div class="paragraph">
<p>Or include only certain properties:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="CodeRay highlight"><code data-lang="groovy"><span class="keyword">def</span> p = <span class="keyword">new</span> Person()
bindData(p, params, [<span class="key">include</span>: [<span class="string"><span class="delimiter">'</span><span class="content">firstName</span><span class="delimiter">'</span></span>, <span class="string"><span class="delimiter">'</span><span class="content">lastName</span><span class="delimiter">'</span></span>]])</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If an empty List is provided as a value for the <code>include</code> parameter then all fields will be subject to binding if they are not explicitly excluded.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The <a href="../ref/Constraints/bindable.html">bindable</a> constraint can be used to globally prevent data binding for certain properties.</p>
</div>
</div>


                <div style="clear:both;margin-top:15px;"></div>
                
                    <div class="toc-item prev-left"><a href="../../guide/GORM.html">&lt;&lt; <strong>7</strong><span>Object Relational Mapping (GORM)</span></a></div>
                
                    <div class="toc-item next-right"><a href="../../guide/traits.html"><strong>9</strong><span>Traits</span> >></a></div>
                
                <div style="clear:both"></div>
            </div>
        </td>
        <td id="col2">
            <div class="local clearfix">
                <div class="local-title">
                    <a href="../../guide/index.html" target="mainFrame">Quick Reference</a>
                    <span class="toggle">(<a href="#" onclick="localToggle(); return false;">hide</a>)</span>
                </div>
                <div class="menu">
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Command Line</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Command%20Line/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/bug-report.html">bug-report</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/clean.html">clean</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/compile.html">compile</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/console.html">console</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-app.html">create-app</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-command.html">create-command</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-controller.html">create-controller</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-domain-class.html">create-domain-class</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-functional-test.html">create-functional-test</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-hibernate-cfg-xml.html">create-hibernate-cfg-xml</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-integration-test.html">create-integration-test</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-interceptor.html">create-interceptor</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-plugin.html">create-plugin</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-profile.html">create-profile</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-script.html">create-script</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-service.html">create-service</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-taglib.html">create-taglib</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/create-unit-test.html">create-unit-test</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/dependency-report.html">dependency-report</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/docs.html">docs</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/generate-all.html">generate-all</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/generate-controller.html">generate-controller</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/generate-views.html">generate-views</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/help.html">help</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/install-templates.html">install-templates</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/list-plugins.html">list-plugins</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/list-profiles.html">list-profiles</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/package-plugin.html">package-plugin</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/package.html">package</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/plugin-info.html">plugin-info</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/profile-info.html">profile-info</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/run-app.html">run-app</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/run-command.html">run-command</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/run-script.html">run-script</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/schema-export.html">schema-export</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/shell.html">shell</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/stats.html">stats</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/stop-app.html">stop-app</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/test-app.html">test-app</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Command%20Line/war.html">war</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Constraints</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Constraints/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Constraints/attributes.html">attributes</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/bindable.html">bindable</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/blank.html">blank</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/creditCard.html">creditCard</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/email.html">email</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/inList.html">inList</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/matches.html">matches</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/max.html">max</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/maxSize.html">maxSize</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/min.html">min</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/minSize.html">minSize</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/notEqual.html">notEqual</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/nullable.html">nullable</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/range.html">range</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/scale.html">scale</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/size.html">size</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/unique.html">unique</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/url.html">url</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/validator.html">validator</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Constraints/widget.html">widget</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Controllers</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Controllers/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Controllers/actionName.html">actionName</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/allowedMethods.html">allowedMethods</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/bindData.html">bindData</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/chain.html">chain</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/controllerName.html">controllerName</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/defaultAction.html">defaultAction</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/errors.html">errors</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/flash.html">flash</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/forward.html">forward</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/grailsApplication.html">grailsApplication</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/hasErrors.html">hasErrors</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/namespace.html">namespace</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/params.html">params</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/redirect.html">redirect</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/render.html">render</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/request.html">request</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/respond.html">respond</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/response.html">response</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/responseFormats.html">responseFormats</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/scope.html">scope</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/servletContext.html">servletContext</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/session.html">session</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/withForm.html">withForm</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Controllers/withFormat.html">withFormat</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Database Mapping</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/autoImport.html">autoImport</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/autoTimestamp.html">autoTimestamp</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/batchSize.html">batchSize</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/cache.html">cache</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/cascade.html">cascade</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/column.html">column</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/comment.html">comment</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/discriminator.html">discriminator</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/dynamicInsert.html">dynamicInsert</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/dynamicUpdate.html">dynamicUpdate</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/fetch.html">fetch</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/id.html">id</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/ignoreNotFound.html">ignoreNotFound</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/indexColumn.html">indexColumn</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/insertable.html">insertable</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/joinTable.html">joinTable</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/lazy.html">lazy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/order.html">order</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/sort.html">sort</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/table.html">table</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/type.html">type</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/updateable.html">updateable</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Database%20Mapping/version.html">version</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Domain Classes</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/addTo.html">addTo</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/attach.html">attach</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/belongsTo.html">belongsTo</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/clearErrors.html">clearErrors</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/constraints.html">constraints</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/count.html">count</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/countBy.html">countBy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/createCriteria.html">createCriteria</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/delete.html">delete</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/discard.html">discard</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/embedded.html">embedded</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/errors.html">errors</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/executeQuery.html">executeQuery</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/executeUpdate.html">executeUpdate</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/exists.html">exists</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/fetchMode.html">fetchMode</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/find.html">find</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findAll.html">findAll</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findAllBy.html">findAllBy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findAllWhere.html">findAllWhere</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findBy.html">findBy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findOrCreateBy.html">findOrCreateBy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findOrCreateWhere.html">findOrCreateWhere</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findOrSaveBy.html">findOrSaveBy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findOrSaveWhere.html">findOrSaveWhere</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/findWhere.html">findWhere</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/first.html">first</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/get.html">get</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/getAll.html">getAll</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/getDirtyPropertyNames.html">getDirtyPropertyNames</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/getPersistentValue.html">getPersistentValue</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/hasErrors.html">hasErrors</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/hasMany.html">hasMany</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/hasOne.html">hasOne</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/ident.html">ident</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/instanceOf.html">instanceOf</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/isAttached.html">isAttached</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/isDirty.html">isDirty</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/last.html">last</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/list.html">list</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/listOrderBy.html">listOrderBy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/load.html">load</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/lock.html">lock</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/mapWith.html">mapWith</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/mappedBy.html">mappedBy</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/mapping.html">mapping</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/merge.html">merge</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/namedQueries.html">namedQueries</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/properties.html">properties</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/read.html">read</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/refresh.html">refresh</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/removeFrom.html">removeFrom</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/save.html">save</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/transients.html">transients</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/validate.html">validate</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/where.html">where</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/whereAny.html">whereAny</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/withCriteria.html">withCriteria</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/withNewSession.html">withNewSession</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/withSession.html">withSession</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Domain%20Classes/withTransaction.html">withTransaction</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Plug-ins</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Plug-ins/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/URL%20mappings.html">URL mappings</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/codecs.html">codecs</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/controllers.html">controllers</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/core.html">core</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/dataSource.html">dataSource</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/domainClasses.html">domainClasses</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/hibernate.html">hibernate</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/i18n.html">i18n</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/logging.html">logging</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/scaffolding.html">scaffolding</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/services.html">services</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Plug-ins/servlets.html">servlets</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Services</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Services/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Services/scope.html">scope</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Services/transactional.html">transactional</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Servlet API</h1><div class="menu-sub">
                        
                            
                            <div class="menu-item"><a href="../../ref/Servlet%20API/request.html">request</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Servlet%20API/response.html">response</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Servlet%20API/servletContext.html">servletContext</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Servlet%20API/session.html">session</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Tag Libraries</h1><div class="menu-sub">
                        
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/Usage.html">Usage</a></div>
                            
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/actionName.html">actionName</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/controllerName.html">controllerName</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/flash.html">flash</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/pageScope.html">pageScope</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/params.html">params</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/request.html">request</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/response.html">response</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/servletContext.html">servletContext</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tag%20Libraries/session.html">session</a>
                            </div>
                            
                            </div>
                    </div>
                    
                    <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Tags</h1><div class="menu-sub">
                        
                            
                            <div class="menu-item"><a href="../../ref/Tags/actionSubmit.html">actionSubmit</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/actionSubmitImage.html">actionSubmitImage</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/applyLayout.html">applyLayout</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/checkBox.html">checkBox</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/collect.html">collect</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/cookie.html">cookie</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/country.html">country</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/countrySelect.html">countrySelect</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/createLink.html">createLink</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/createLinkTo.html">createLinkTo</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/currencySelect.html">currencySelect</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/datePicker.html">datePicker</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/each.html">each</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/eachError.html">eachError</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/else.html">else</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/elseif.html">elseif</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/external.html">external</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/field.html">field</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/fieldError.html">fieldError</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/fieldValue.html">fieldValue</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/findAll.html">findAll</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/form.html">form</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/formatBoolean.html">formatBoolean</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/formatDate.html">formatDate</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/formatNumber.html">formatNumber</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/grep.html">grep</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/hasErrors.html">hasErrors</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/header.html">header</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/hiddenField.html">hiddenField</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/if.html">if</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/img.html">img</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/include.html">include</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/isAvailable.html">isAvailable</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/isNotAvailable.html">isNotAvailable</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/javascript.html">javascript</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/join.html">join</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/layoutBody.html">layoutBody</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/layoutHead.html">layoutHead</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/layoutTitle.html">layoutTitle</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/link.html">link</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/localeSelect.html">localeSelect</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/message.html">message</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/meta.html">meta</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/pageProperty.html">pageProperty</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/paginate.html">paginate</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/passwordField.html">passwordField</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/radio.html">radio</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/radioGroup.html">radioGroup</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/render.html">render</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/renderErrors.html">renderErrors</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/resource.html">resource</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/select.html">select</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/set.html">set</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/sortableColumn.html">sortableColumn</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/submitButton.html">submitButton</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/textArea.html">textArea</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/textField.html">textField</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/timeZoneSelect.html">timeZoneSelect</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/unless.html">unless</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/uploadForm.html">uploadForm</a>
                            </div>
                            
                            <div class="menu-item"><a href="../../ref/Tags/while.html">while</a>
                            </div>
                            
                            </div>
                    </div>
                    
                </div>
            </div>
        </td>
    </tr>
</table>

<div id="footer">
    Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.
    
</div>

<script type="text/javascript" src="../js/docs.js"></script>

</body>
</html>
